<!DOCTYPE html>
<%@page import="domain.milk.Milk, domain.milk.WoodsCurves, domain.milk.SeasonalityMilk"%>
<%@page import="svc.MilkSvc, constants.Constants, utils.Utility"%>
<%
	String userName = "";
	if (request.getSession().getAttribute("name") != null) {
		userName = request.getSession().getAttribute("name").toString();
	}
	if (!userName.equals("")) {
		String fileNo = (String)session.getAttribute("fileNo");
		double unit = (Double)session.getAttribute("unit");
		
		Milk milk = (Milk) request.getAttribute("milk");
		SeasonalityMilk seasonality = milk.getSeasonalityMilk();
		WoodsCurves wood = milk.getWoodCurves();
		
%>
<html lang="en">
<head>
<title>Set Values</title>
<meta name="viewport"
	content="width=device-width, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
<meta name="description" content="">
<meta name="author" content="">

<!-- Le styles -->
<link href="../css/bootstrap.css" rel="stylesheet">
<!--  <link href="../css/bootstrap-responsive.css" rel="stylesheet">-->
<link href="../css/docs.css" rel="stylesheet">
<link href="../css/google-code-prettify/prettify.css" rel="stylesheet">
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
      <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->




<style type="text/css">
body {
	padding-top: 60px;
	padding-bottom: 40px;
}
</style>

</head>

<body onLoad="displayResults(1);displayResults(2);displayResults(3)">

	<div class="navbar navbar-inverse navbar-fixed-top">
		<div class="navbar-inner">
			<div class="container">
				<a class="btn btn-navbar" data-toggle="collapse"
					data-target=".nav-collapse"> <span class="icon-bar"></span> <span
					class="icon-bar"></span> <span class="icon-bar"></span>
				</a> <a class="brand" href="#">DairyVIP Project</a>
				<div class="nav-collapse collapse">
					<p class="navbar-text pull-right">
						Logged in as <a href="#" class="navbar-link"><%=userName%></a>
					</p>
					<ul class="nav">
						<li><a href="../jsp/index.jsp">Home</a></li>
						<li><a href="../jsp/acknowledgements_contro.jsp">Acknowledgements/Contributors</a></li>
						<li><a href='../jsp/dataset.jsp'>My DairyVIP</a></li>
					</ul>
				</div>
				<!--/.nav-collapse -->
			</div>
		</div>
	</div>



	<!-- Docs nav
    ================================================== -->


	<!--<ul class="nav nav-list bs-docs-sidenav">
          <li><a href="woods"><i class="icon-chevron-right"></i> Wood's curves</a></li>
          <li><a href="#fit"><i class="icon-chevron-right"></i> Fit curves</a></li>
          <li><a href="#florida"><i class="icon-chevron-right"></i> Florida curves</a></li>
          <li><a href="#diphasic"><i class="icon-chevron-right"></i> Diphasic curves</a></li>
           </ul>-->

	<div class="container">
		<div class="pagination ">
			<ul>
				<li><a href="../jsp/inputMisc">Misc</a></li>
				<li><a href="../jsp/inputPrice">Price</a></li>
				<li class="active"><a href="#">Milk</a></li>
				<li><a href="../jsp/inputCull">Cull</a></li>
				<li><a href="../jsp/inputRepro">Repro</a></li>
				<li><a href="../jsp/inputBW">Bodyweight</a></li>
			</ul>
		</div>
	</div>

	<div class="container">

		<form id="saveMilk" name="saveMilk" method="post">
			<div class="container0">
			<p>&nbsp;&nbsp;&nbsp;</p>
				<p title=	
"Wood's incomplete gamma function.
Source:
P.D.P. Wood
Algebraic model of the lactation curve in cattle
Nature 216 (1969): 164-165">
					<strong>Wood's curves</strong>
				</p>
				
				<% for(int lact=1; lact<=3; lact++) {%>
				<table id="lactinput<%= lact %>" cellspacing="0" cellpadding="1"
					style="background-color: #f5f5f5; font-size: 12px" border="1">
					<tbody>
						<tr>
							<td align="left">+/- (abs):</td>
							<td align="left"><input type="text" class="span1" value=<%= seasonality.getAbsAdjustment()[lact] %>
								name="mabs<%= lact %>" id="mabs<%= lact %>"
								style="width: 40px; height: 15px; font-size: 80%; padding: 2px; margin: 0px"
								onChange="displayResults(<%= lact %>);"></td>
						</tr>
						<tr>
							<td align="left">+/- (%):</td>
							<td align="left"><span style="display: inline"><input
									class="span1" id="pct<%= lact %>" size="4" type="text" value=<%= 100*seasonality.getPctAdjustment()[lact] %>
									name="pct<%= lact %>"
									style="width: 40px; height: 15px; font-size: 80%; padding: 2px; margin: 0px; display: inline"
									onChange="displayResults(<%= lact %>);"></span></td>
						</tr>
						<tr>
							<td align="left">Peak Yield (Kg/Day)</td>
							<td align="left"><input
								style="width: 40px; height: 15px; font-size: 80%; padding: 2px; margin: 0px"
								type="text" class="span1" value=<%= wood.getLactA()[lact] %> name="wood<%= lact %>a"
								id="wooda<%= lact %>" size="8" onChange="displayResults(<%= lact %>)"></td>
						</tr>
						<tr>
							<td align="left">Days in Milk at Peak</td>
							<td align="left"><input
								style="width: 40px; height: 15px; font-size: 80%; padding: 2px; margin: 0px"
								type="text" class="span1" value=<%= wood.getLactB()[lact] %> name="wood<%= lact %>b" id="woodb<%= lact %>"
								onChange="displayResults(<%= lact %>)"></td>
						</tr>
						<tr>
							<td align="left">Monthly Decline After Peak (%)</td>
							<td align="left"><input
								style="width: 40px; height: 15px; font-size: 80%; padding: 2px; margin: 0px"
								type="text" class="span1" value=<%= wood.getLactC()[lact]*100 %> name="wood<%= lact %>c"
								id="woodc<%= lact %>" size="8" onChange="displayResults(<%= lact %>)"></td>
						</tr>

						<% for(int mim=1; mim<=24; mim++) {%>
							<tr>
								<td>&nbsp;</td>
								<td><span id="lact<%= lact %>_<%= mim %>"></span></td>
							</tr>
						<% } %>
						
					</tbody>
				</table>
				<p></p>
				<% } %>


				<p>Change any value in the input field, you can get the
					computing results</p>
			</div>

			<div class="span9" style="margin-top: 5px">
				<legend>
					<small>MILK YIELD (/Cow/Day)</small>
				</legend>
				<p>
					<input class="btn" type="button" onclick="save(this.form)" value="Save" />
					<input class="btn" type="button" onclick="saveAnalyze(this.form)" value="Save and Analyze" />
				</p>
				
				<% for(int lact=1; lact<=3; lact++) {%>
				<table cellspacing="0" cellpadding="1">
					<thead>
						<tr>
							<th colspan="12">Lactation <%= lact %></th>
						</tr>
						<tr>
							<th>Month</th>
							<th>&nbsp;&nbsp;</th>
							
							<% for(int sea=1; sea<=12; sea++) {%>
								<th><%= Constants.MONTHS[sea] %></th>
							<% } %>
							
						</tr>
					</thead>
					<tbody>
						<tr>
							<td align="left"><strong>Seasonality</strong></td>
							<td align="left">&nbsp;&nbsp;</td>
							
							<% for(int sea=1; sea<=12; sea++) {%>
							<td align="left">
								<input value=<%=(String) Utility.roundToZero(100*seasonality.getMonthlySeasonality()[lact][sea]) %> id="msea<%= lact %>_<%= sea %>" name="msea<%= lact %>_<%= sea %>"
										style="width: 20px; height: 15px; font-size: 80%; display: inline"
										class="span1" size="4" type="text" onChange="displayResults(<%= lact %>)">%
							</td>
							<% } %>
						</tr>
					</tbody>
				</table>


				<table id="myTable<%= lact %>"
					style="background-color: #f5f5f5; border: solid 1px #ccc;  font-size: 12px"
					cellspacing="0" cellpadding="1">

				</table>
				<p>&nbsp;</p>
				<p>&nbsp;</p>
				<% } %>
				
			</div>
			<!-- two hidden input mseasonality and mseaavg -->

			<input type="hidden" value="100" name="mseaavg" id="mseaavg" />
			<input id="units" name="units" class="span_1" type="hidden" value="kg" />
			<input type="hidden" value="100" name="mseasonality" id="mseasonality" />
			
		</form>
	</div>

	<p>&nbsp;</p>
	<footer class="footer">
		<%@ include file="../inc/footer.html"%>
	</footer>


	<!-- Le javascript
    ================================================== -->
	<!-- Placed at the end of the document so the pages load faster -->


	<script type="text/javascript" src="../js/jquery.js"></script>
	<script src="../js/bootstrap.js"></script>
	<%@ include file="floridacurvedata.html"%>
	<script>  
$(function ()  
{ $("#example1").popover({trigger: 'click',placement:'left'});  
  $("#example2").popover({trigger: 'click',placement:'right'});  
  $("#example3").popover({trigger: 'hover'});  
  $("#example4").popover({trigger: 'hover',placement:'right'}); 
});  

</script>
	<script src="../js/computing.js"></script>
	<script language="javascript">
		function save(form)/*function to check userid & password*/
		{
			form.action = '../jsp/saveMilk';
			form.submit();
			return true;
		}
		function saveAnalyze(form)/*function to check userid & password*/
		{
			form.action = '../jsp/saveAnalyzeMilk';
			form.submit();
			return true;
		}
	</script>

</body>
</html>
<%}else
out.print("Please <a href='../jsp/login.jsp'>log in</a> first!");
%>